package com.fs.sys.entityservice.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fs.sys.bean.dto.InboxMsgDTO;
import com.fs.sys.bean.query.InboxMsgQuery;
import com.fs.sys.domain.entity.InboxMsgEntity;
import com.fs.sys.domain.mapper.InboxMsgMapper;
import com.fs.sys.entityservice.InboxMsgEntityService;
import com.fs.common.base.service.AbstractBaseEntityService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 站内信服务实现 
 * @author Coder Generator 2025-06-06 11:03:12 
 **/
@Service
public class InboxMsgEntityServiceImpl extends AbstractBaseEntityService<InboxMsgEntity, InboxMsgDTO, InboxMsgMapper, InboxMsgQuery> implements InboxMsgEntityService {
    @Override
    protected QueryWrapper<InboxMsgEntity> queryToWrapper(InboxMsgQuery query) {
        return this.createQueryWrapper()
                .eq(StringUtils.isNotBlank(query.getId()), "id", query.getId())
                .in(null != query.getIds(), "id", query.getIds())
                .and(StringUtils.isNotBlank(query.getReceiverId()), w -> {
                    w.eq("receiver_id", query.getReceiverId())
                            .or(w1 -> w1.isNull("receiver_id"));
                })
                .and(StringUtils.isNotBlank(query.getKey()), w -> {
                    w.like("title", query.getKey())
                            .or(w1 -> w1.like("content", query.getKey()));
                })
                .eq(null != query.getStatus(), "status", query.getStatus())
                .orderByDesc("create_time");
    }
}